package com.zmn.oms.zmn.business.interfaces.work;

import com.zmn.oms.common.dio.normal.query.GrabQueryDIO;
import com.zmn.oms.common.dro.normal.master.NonGridGrabOrderDRO;
import com.zmn.oms.common.exception.OmsBaseException;
import com.zmn.oms.model.dto.graborder.GrabConfigDTO;
import com.zmn.oms.model.dto.graborder.GrabOrderDTO;
import com.zmn.oms.model.dto.graborder.GrabOrderWorkDTO;
import com.zmn.oms.model.dto.graborder.GrabWorkQuery;
import com.zmn.oms.model.dto.work.modify.must.OrderWorkGrabDTO;
import com.zmn.oms.model.entity.work.OrderWork;

import java.util.List;

/**
 * 类描述：工单抢单
 *
 * @author liuying
 * @date 2021/07/19 11:45
 */
public interface OrderWorkGrabBService {

    /**
     * 工程师抢单列表
     *
     * @param grabWorkQuery
     * @return
     */
    List<GrabOrderDTO> listGrabOrderByMasterInfo(GrabWorkQuery grabWorkQuery) throws OmsBaseException;

    /**
     * 工程师无网格抢单列表
     *
     * @param grabQueryDIO
     * @return
     */
    List<NonGridGrabOrderDRO> listNonGridGrabOrder(GrabQueryDIO grabQueryDIO) throws OmsBaseException;

    /**
     * 抢单
     *
     * @param grabOrderWorkDTO
     * @throws OmsBaseException
     */
    void grabOrderWork(GrabOrderWorkDTO grabOrderWorkDTO) throws OmsBaseException;

    /**
     * 抢单
     *
     * @param grabOrderWorkDTO
     * @throws OmsBaseException
     */
    void nonGridGrabOrderWork(GrabOrderWorkDTO grabOrderWorkDTO) throws OmsBaseException;

    /**
     * 抢单-派单
     *
     * @param grabOrderWorkDTO
     * @throws OmsBaseException
     */
    void grabDistributeOrder(GrabOrderWorkDTO grabOrderWorkDTO) throws OmsBaseException;

    /**
     * 更新抢单类型
     *
     * @param orderWorkGrabDTO
     */
    void saveGrabType(OrderWorkGrabDTO orderWorkGrabDTO) throws OmsBaseException;

    /**
     * 抢单配置
     *
     * @param orderWork
     * @return GrabConfigDTO
     * @throws OmsBaseException
     */
    GrabConfigDTO grabConfig(OrderWork orderWork) throws OmsBaseException;

    /**
     * 查看是否可抢单
     *
     * @param orderWork
     * @return GrabConfigDTO
     * @throws OmsBaseException
     */
    GrabConfigDTO checkGrab(OrderWork orderWork) throws OmsBaseException;

    /**
     * 从抢单池中移除， 并更新抢单类型
     *
     * @param workId
     * @throws OmsBaseException
     */
    void removeFromGrabOrder(Long workId) throws OmsBaseException;

    /**
     * 将订单从抢单池删除
     *
     * @param workId
     * @throws OmsBaseException
     */
    void deleteGrabOrderWithLock(Long workId) throws OmsBaseException;
}
